#ifndef TREE_H
#define TREE_H

#pragma warning(disable: 4290)
#pragma warning(disable: 4018)

#include <boost/serialization/base_object.hpp>

class tree_error : public std::logic_error 
{
public:
tree_error(const std::string &error) : logic_error(error) { }
};

class Tree
{
   public:
	  Tree();
	  ~Tree();	  
	  
	  void add(Location *&n) throw(tree_error);
	  void remove(std::string s) throw(tree_error);
	  Location * find_l(std::string name);
	  Location * find_exit(Location *&c, std::string &location);
	  void save(std::string filename);
	  void print_tree();
	  Location *  load(std::string mapname);
	  void emptytree();
	  
   private: 
	  friend class boost::serialization::access;
	  template <class Archive>
	  void serialize(Archive & ar, const unsigned int version){
		  ar & root_;
	  }
	  void add(Location *&p, Location *&n) throw(tree_error);
	  void remove(Location *&p, std::string &s) throw(tree_error);
	  void save(Location*p, const char*, const char*, const char*);
	  void print_tree(Location* p);
	  void emptytree(Location* p);
	  Location * find_min(Location *p) throw(tree_error);
	  Location * find_l(std::string &name, Location *p);
	  Location *root_;
};
#endif
